﻿using System;
using System.Text;
using System.Web;
using System.Net;
using System.Collections;
using System.Threading;

namespace FindDomains
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length <= 0)
            {
                Usage();
                return;
            }
            string IP = args[0];
            //string IP = "";
            if (System.IO.File.Exists("appid.txt"))
                FindDomains.WebSample.AppId = System.IO.File.ReadAllText("appid.txt");
            else
            {
                Console.WriteLine("");
                Console.WriteLine("There is no appid.txt file on program directory. See Usage.txt for more information.");
                return;
            }
            if ((FindDomains.WebSample.AppId.ToString().Length < 40))
            {
                Console.WriteLine("Invalid appid.");
                Console.WriteLine("Register a new one from http://www.bing.com/developers/createapp.aspx");
                return;
            }
            FindDomains.WebSample.AppId = FindDomains.WebSample.AppId.Substring(0, 40);
            DomainFetcher domainFetcher = new DomainFetcher(IP);
        }
        static void Usage()
        {
            Console.WriteLine("");
            Console.WriteLine("Mesut Security Research Tech.");
            Console.WriteLine("Proudly presents :");
            Console.WriteLine("");
            Console.WriteLine("------------->   FindDomains v0.1    <-------------");
            Console.WriteLine("");
            Console.WriteLine("Returns located domain names for specified IP address or domain name.");
            Console.WriteLine("Uses Bing search engine, so internet connection is required.");
            Console.WriteLine("");
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("");
            Console.WriteLine("First do that : ");
            Console.WriteLine("Register and appid from \"Bing Developers\" http://www.bing.com/developers/createapp.aspx");
            Console.WriteLine("Copy it to the appid.txt that is located program's directory.");
            Console.WriteLine("");
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("");
            Console.WriteLine("Example Usage : ");
            Console.WriteLine("FindDomains.exe 1.2.3.4");
            Console.WriteLine("FindDomains.exe www.hotmail.com");
            Console.WriteLine("");
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("");
            Console.WriteLine("Contact : Mesut Timur");
            Console.WriteLine("E-Mail : mesut_timur@hotmail.com");
            Console.WriteLine("Web : http://code.google.com/p/finddomains");
            Console.WriteLine("");
        }

 
    }
}
